Skip to content

FIX-2346: conversations open at their end, with no scroll to watch - #4229

Merged
jhoffner merged 4 commits into
mainfrom
claude/project-thread-9h3wvr
Oct 30, 2026
Merged

jhoffner merged 4 commits into
mainfrom
claude/project-thread-9h3wvr

Conversation

@jhoffner

Copy link
Copy Markdown
Collaborator

Requested by Jake · project thread

Problem

In every app (DevTool, Shift Manager, the Claude Code-style lab, the Teammates lab), opening or switching to a conversation scrolled visibly from the top down to the end. Each app had its own scroll code, so the fix had nowhere single to land.

What changes

One rule, in one place: useFollowLatest in @flow-state-dev/react.

  • A feed that opens (mount, a resetKey change such as a session switch, or its first read filling an empty feed) lands at the end before paint, with behavior: "instant". It stays "opening" until the frame after it first overflows, and any jump longer than one view is also instant (a load, not an arrival).
  • After that, content arriving while the reader is at the end glides (smooth). This keeps FIX-2338's live behavior.
  • A reader who scrolled up is never pulled down. Only scrolling up lets go, because a smooth follow passes points far from the end on its way down. atEnd drives "Jump to latest", follow() goes back, and stay() holds the feed before history loads above it.

Apps moved onto it

App Where
DevTool stream view. It used to smooth-scroll on load, and its scroll listener never attached because the container mounts after the empty state
Shift Manager Conversation and TaskSession. lib/follow.ts is deleted and its tests moved to the hook
Teammates lab conversation (resetKey: sessionId) and the session popup. lib/stick-to-bottom.ts is deleted
Claude Code-style lab main thread (resetKey: session.id, sending a line follows), thread view (resetKey: task.id) and the task sheet. Before, every count change scrolled the reader down

ui registry conversation (with the kitchen-sink copy, kept byte-identical for registry-drift): ScrollOnNewRequest now lands a first load or a session switch instantly, in a layout effect gated on the container being attached. Only a request that follows one already on screen scrolls smoothly.

Docs: the @flow-state-dev/react README has a useFollowLatest section, and apps/docs common-components covers ScrollOnNewRequest. Changeset: react, devtool and shift-manager, patch. ui is private.

Verification

Regression tests, each with a control run against main's source files swapped back in:

  • packages/devtool/test/stream-view-scroll.test.tsx: history lands at the end instantly, a live request glides, and a reader who scrolled up stays put. Both fail on main.
  • labs/teammates/test/screen.test.tsx: opens and switches workers at the end instantly, and the popup opens at its latest step and then glides. Both fail on main. The existing streamed-follow test now lays the feed out, so it still proves the smooth follow.
  • labs/claude-code-style/test/screen.test.tsx: a session opens at the end instantly and a reader scrolled up isn't pulled down, and the sheet opens at the end. Both fail on main.
  • packages/ui/test/render/conversation-scroll.test.tsx: 3/3 fail on main (all smooth).
  • packages/react/test/useFollowLatest.test.ts: the moved follow tests plus open, first-read, switch, live-glide and scrolled-up cases.
  • Mutation control: making the hook always follow fails the Claude Code-style lab's and the Teammates lab's scrolled-up tests.

The test suites pass for react (423), devtool (456), ui (239) and teammates (64). Typecheck passes for all touched packages plus kitchen-sink, and package-boundaries and test-typecheck validation pass. Two failures are not from this PR:

  • claude-code-style inventory.test.ts (README has no inventory block): it also fails on origin/main.
  • shift-manager command.test.ts needs dist-client to be built, and the pages aren't built in this environment.

Not yet checked: how it feels in a real browser. happy-dom lays nothing out, so the tests size the feeds by hand.


Generated by Claude Code

Every app opened or switched to a conversation by scrolling visibly from
the top down to the end. Each had its own scroll code, so the rule now
lives once in @flow-state-dev/react as useFollowLatest: a feed that opens
(mount, a resetKey change, or its first read filling it) lands at the end
before paint; content arriving live while the reader is at the end glides;
a reader who scrolled up is never pulled down.

- DevTool stream view, Shift Manager (conversation + task session), the
  Teammates lab (conversation + session popup) and the Claude Code-style
  lab (main thread, thread view, task sheet) use it. Shift Manager's
  lib/follow.ts and the Teammates lab's stick-to-bottom.ts are gone; their
  tests move to the hook.
- The ui registry's ScrollOnNewRequest (and the kitchen-sink copy) lands a
  first load or session switch instantly, before paint; only a request
  that follows one on screen scrolls smoothly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiHKUc1cT214v6KRkYo
@jhoffner jhoffner self-assigned this Oct 30, 2026
@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated
flow-state-dev-docs Ignored Ignored Oct 30, 2026 1:12am UTC
flow-state-dev-kitchen-sink Ignored Ignored Oct 30, 2026 1:12am UTC
flow-state-dev-ui Ignored Ignored Preview Oct 30, 2026 1:12am UTC

Request Review

@linear-code

linear-code Bot commented Oct 30, 2026

Copy link
Copy Markdown

FIX-2346

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T01:01:38.377415Z 2879c89 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@jhoffner

Copy link
Copy Markdown
Collaborator Author

@codex review

Copy link
Copy Markdown
Collaborator Author

Second look + architecture pass

Overall: the approach is right. One hook in @flow-state-dev/react replacing five hand-rolled scroll rules is the leaner shape, and deleting follow.ts / stick-to-bottom.ts is real consolidation. Findings below, ranked. None block, but 1 and 2 are worth deciding before merge. I read the code and diff only; I did not run the suites.

1. A second scroll rule survives in ui conversation (and the kitchen-sink copy)

packages/ui/registry/components/conversation.tsx still owns its own isAtBottom / scrollToBottom, and this PR adds ready / attach plumbing to it. That is a parallel implementation of the rule the hook now owns, and the PR has to patch it separately (plus keep the byte-identical kitchen-sink copy in sync) to get the same "open instantly" behavior.

  • Other registry components already import @flow-state-dev/react, so the dependency isn't new for the registry.
  • The behavior differs on purpose: ScrollOnNewRequest does not follow streaming, while the hook does. If that is the product intent, say so in the hook docs and leave the split. If it isn't, Conversation could use useFollowLatest and ready / attach would go away.
  • Recommendation: decide this explicitly in the PR description. Don't carry two rules silently.

2. Remaining ad-hoc scrollers in the same surfaces

packages/devtool/.../trace-view.tsx (same package as the migrated stream-view), packages/ui/registry/components/debate.tsx (and its shift-manager and kitchen-sink copies) still call scrollIntoView / scrollTo by hand. If they are feeds, they have the same open-from-the-top problem. If they are not feeds, a one-line note saying so avoids the next person "fixing" them.

3. Small race in useFollowLatest

The resetKey layout effect sets opening.current = true, but the requestAnimationFrame scheduled by the mount effect (frame) is not cancelled. If a session switch lands within a frame of the first overflow, that pending rAF clears opening before the new session's content fills in, and the new session glides instead of landing instantly. Fix: keep frame in a ref and cancel it in the reset effect. Cheap, and it needs a test (switch immediately after mount).

4. Verification gap

Per the PR, nothing was checked in a real browser, and happy-dom lays out nothing. The behavior here is entirely about paint timing and scroll-behavior, which is exactly what those tests can't see. Worth a manual pass on one app (a session switch in the Teammates lab, and DevTool stream view load) before merge, or a Playwright check, since Chromium is available in the repo's environment.

Not flagged

  • Hook API size is proportionate (ref / atEnd / follow / stay), and startAtEnd / stay each have a caller or doc'd purpose.
  • Changeset scope and README / docs coverage look right.

Generated by Claude Code

@github-actions

Copy link
Copy Markdown
Contributor

Mechanism check (advisory, never blocks)

Rows from docs/mechanisms/mechanisms.yaml · labels: none

New export Package Mechanism
useFollowLatest @flow-state-dev/react react

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: cf1d91e30b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiHKUc1cT214v6KRkYo
#4198 dropped the README's inventory markers, so the lab's inventory test
is red on main and on every PR. Markers restored and the table
regenerated with node scripts/inventory.mjs --write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiHKUc1cT214v6KRkYo

Copy link
Copy Markdown
Collaborator Author

Test (3/3) failed in labs/claude-code-style/test/inventory.test.ts: the README's inventory is out of date. The failure isn't this PR's. #4198 deleted the README's <!-- inventory:start/end --> block, so the test is red on main too. I've restored the markers and regenerated the table in 2879c89, and the lab's tests now pass locally (60/60). Once main has its own fix, this change does nothing.


Generated by Claude Code

The README stats tables were removed on purpose; #4127 fixes main by
dropping the lab's table check instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NczDiHKUc1cT214v6KRkYo

Copy link
Copy Markdown
Collaborator Author

I've reverted the README inventory restore in e62cf54. The stats tables were removed on purpose, and #4127 fixes main by dropping the Claude Code-style lab's table check instead.

Until #4127 merges, Test (3/3) will fail on labs/claude-code-style/test/inventory.test.ts here, the same as on main. That failure doesn't come from this PR's change. Everything else was green on the previous head.


Generated by Claude Code

@jhoffner
jhoffner merged commit cff4354 into main Oct 30, 2026
17 of 19 checks passed
@jhoffner
jhoffner deleted the claude/project-thread-9h3wvr branch October 30, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants